import { createWebHashHistory, createRouter } from 'vue-router';
import Layout from '@/extension/layout/index.vue';

// 路由守卫
import guarder from './guarder';

// 公共路由
export const constantRoutes = [
	{
		path: '/Layout',
		name: '/Layout',
		component: markRaw(Layout),
		children: [
			{
				path: '/profile',
				name: '/profile',
				component: () => import('../views/system/user/profile/index.vue'),
				meta: {
					title: '个人信息',
					hideTabs: true
				}
			}
		]
	},
	{
		path: '/chart',
		name: '/chart',
		component: () => import('@/views/chart/index.vue'),
		children: [
			{
				path: '/chart/home/:websiteId/:pageId?',
				name: 'ChartHome',
				component: () => import('@/views/chart/ContentEdit/index.vue'),
				meta: {
					title: '工作空间',
					hideTabs: true
				}
			}
		]
	},
	{
		path: '/chart/preview',
		name: '/chart/preview',
		component: () => import('@/extension/ParentView/index.vue'),
		children: [
			{
				path: '/chart/preview/:websiteId/:pageId',
				name: 'ChartPreview',
				component: () => import('@/views/preview/index.vue'),
				meta: {
					title: '预览',
					hideTabs: true
				}
			}
		]
	},
	{
		path: '/scene/3DEdit/:projectId?',
		name: '3DEdit',
		component: () => import('@/views/scene/3DEdit/index.vue'),
		meta: {
			title: '3D编辑器',
			hideTabs: true
		}
	},
	{
		path: '/login',
		name: '/login',
		component: () => import('../extension/login/index.vue'),
		meta: {
			title: '登陆页面',
			hideTabs: true
		}
	},
	{
		path: '/403',
		name: '/403',
		component: () => import('../extension/exception/403.vue'),
		meta: {
			title: '403页面',
			hideTabs: true
		}
	},
	{
		path: '/404',
		name: '/404',
		component: () => import('../extension/exception/404.vue'),
		meta: {
			title: '404页面',
			hideTabs: true
		}
	},
	{
		path: '/500',
		name: '/500',
		component: () => import('../extension/exception/500.vue'),
		meta: {
			title: '500页面',
			hideTabs: true
		}
	},
	{
		path: '/512',
		name: '/512',
		component: () => import('../extension/exception/512.vue'),
		meta: {
			title: '512页面',
			hideTabs: true
		}
	}
];

const router = createRouter({ history: createWebHashHistory(), routes: constantRoutes });

guarder(router);

export default router;
